import request from '@/utils/request'

// 查询服务显示信息列表
export function listShow(query) {
  return request({
    url: '/servicemanage/show/list',
    method: 'get',
    params: query
  })
}

// 查询服务显示信息详细
export function getShow(id) {
  return request({
    url: '/servicemanage/show/' + id,
    method: 'get'
  })
}

// 新增服务显示信息
export function addShow(data) {
  return request({
    url: '/servicemanage/show',
    method: 'post',
    data: data
  })
}

// 修改服务显示信息
export function updateShow(data) {
  return request({
    url: '/servicemanage/show',
    method: 'put',
    data: data
  })
}

// 删除服务显示信息
// 删除服务显示信息
export function delShow(id, deleted) {
  // 把deleted作为查询参数
  return request({
    url: `/servicemanage/show/${id}`,
    method: 'delete',
    params: { deleted }
  })
}

/**
 * 获取完整的服务树形结构
 * @returns {Promise<AxiosResponse>} 返回服务树数据的Promise
 */
export function servicemanageTree(query) {
  return request({
    url: '/servicemanage/show/list1',
    method: 'get',
     params: query
  })
}

/**
 * 根据一级标题ID获取子树
 * @param {number} firstLevelId - 一级标题ID
 * @returns {Promise<AxiosResponse>} 返回子树数据的Promise
 */
export function getServiceSubTree(firstLevelId) {
  return request({
    url: `/servicemanage/show/${firstLevelId}`,
    method: 'get',
  })
}
